<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->

@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb mbx_fl_10">
        <a href="">首页</a>
        <a href="">系统权限管理</a>
        <a><cite>修改密码</cite></a>
    </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        <span class="x-red">*</span>用户名
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" value="{{ $data['username'] }}"
                               class="layui-input layui-disabled">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">密码必须为“6~20位的字符”。不修改请留空</div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">确认密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password1" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">密码必须为“6~20位的字符”。不修改请留空</div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <input type="hidden" name="id" value="{{ $data['id'] }}">
                    <button class="layui-btn" lay-filter="add" lay-submit="">提交</button>
                </div>
            </form>
        </div>
    </div>
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)', function (data) {
                console.log(data);
                //发异步，把数据提交给php
                $.ajax({
                    type: 'POST',
                    url: "/admin/system/userPassword?id={{ $data['id'] }}",
                    data: data.field,
                    dataType: 'json',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    },
                    success: function (data) {
                        // console.log(data);
                        if (data.code == 1) {
                            layer.alert("提交成功", {
                                    time: 2000,
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();
                                    // location.href="/admin/loginout";
                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        } else {
                            layer.alert(data.msg)
                        }
                    },
                    error: function (xhr, type) {
                        alert('Ajax error!')
                    }
                });

                return false;
            });

        });
    </script>
    <script>
        layui.use('laydate',
            function () {
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#start', //指定元素
                    type: 'datetime'
                });

                //执行一个laydate实例
                laydate.render({
                    elem: '#end', //指定元素
                    type: 'datetime'
                });
            });
    </script>

@endsection
